package cn.juque.common.constants;

/**
 * @author nuoka
 */
public enum MessageEnum implements BaseMessageEnum {

    /**
     * enum
     */
    OK("200", "操作成功"),
    BAD_REQUEST("400", "Bad Request"),
    PARAM_NULL("1004", "入参不能为空"),
    PAGE_NULL("1010", "分页参数不能为空"),
    PARAM_ERROR("1005", "入参错误"),
    CREATE_WX_PREPAY_ID_ERROR("1006", "创建微信预支付订单异常"),
    WX_PAY_VERIFY_ERROR("1007", "微信支付签名校验失败"),
    WX_CLOSE_ORDER_ERROR("1008", "关闭微信订单失败"),
    WX_QUERY_ORDER_ERROR("1009", "查询订单异常"),
    NO_LOGIN("401", "您尚未登录或登录时间过长,请重新登录!"),
    SMS_CHECK_CODE_FAIL("402", "短信验证码失效或已过期"),
    SYSTEM_ERROR("500", "服务异常"),
    SYSTEM_FAIL("501", "服务操作失败"),
    SAVE_FAIL("502", "保存失败"),
    UPDATE_FAIL("503", "更新失败"),
    DELETE_FAIL("504","删除失败"),

    ;

    /**
     * 消息码
     */
    private String code;

    /**
     * 消息
     */
    private String msg;

    MessageEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    /**
     * 判断编码是否一致
     *
     * @param msgEnum 消息枚举
     * @param code    消息编码
     * @return Boolean
     */
    public static Boolean equals(MessageEnum msgEnum, String code) {
        if (msgEnum.getCode().equals(code)) {

            return Boolean.TRUE;
        }

        return Boolean.FALSE;
    }
}
